import request from '@/utils/request'

// 查询设备维护记录列表
export function listMaintenance(query) {
  return request({
    url: '/equipment/maintenance/list',
    method: 'get',
    params: query
  })
}

// 查询设备维护记录详细
export function getMaintenance(maintenanceId) {
  return request({
    url: '/equipment/maintenance/' + maintenanceId,
    method: 'get'
  })
}

// 新增设备维护记录
export function addMaintenance(data) {
  return request({
    url: '/equipment/maintenance',
    method: 'post',
    data: data
  })
}

// 修改设备维护记录
export function updateMaintenance(data) {
  return request({
    url: '/equipment/maintenance',
    method: 'put',
    data: data
  })
}

// 删除设备维护记录
export function delMaintenance(maintenanceId) {
  return request({
    url: '/equipment/maintenance/' + maintenanceId,
    method: 'delete'
  })
}

// 导出设备维护记录
export function exportMaintenance(query) {
  return request({
    url: '/equipment/maintenance/export',
    method: 'get',
    params: query
  })
}

// 校验维护编号唯一性
export function checkMaintenanceCodeUnique(maintenanceCode) {
  return request({
    url: '/equipment/maintenance/checkMaintenanceCodeUnique',
    method: 'post',
    data: { maintenanceCode }
  })
}

// 根据设备ID查询维护记录
export function getMaintenanceByEquipmentId(equipmentId) {
  return request({
    url: '/equipment/maintenance/equipment/' + equipmentId,
    method: 'get'
  })
}

// 根据维护编号查询
export function getMaintenanceByCode(maintenanceCode) {
  return request({
    url: '/equipment/maintenance/code/' + maintenanceCode,
    method: 'get'
  })
}

// 根据维护类型查询
export function getMaintenanceByType(maintenanceType) {
  return request({
    url: '/equipment/maintenance/type/' + maintenanceType,
    method: 'get'
  })
}

// 根据维护状态查询
export function getMaintenanceByStatus(maintenanceStatus) {
  return request({
    url: '/equipment/maintenance/status/' + maintenanceStatus,
    method: 'get'
  })
}